﻿/*	
	stencil - action script 3 isometric game engine.

	http://code.google.com/p/stencilas3/
	
	Copyright (c) 2010 Max Zhuravkov, All Rights Reserved.

	Permission is hereby granted, free of charge, to any person obtaining a copy of
	this software and associated documentation files (the "Software"), to deal in
	the Software without restriction, including without limitation the rights to
	use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
	of the Software, and to permit persons to whom the Software is furnished to do
	so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
*/
package stencil.core.engine.display 
{
	import flash.events.IEventDispatcher;
	import stencil.core.engine.IGrid;
	import stencil.core.engine.ITileSection;
	import stencil.core.engine.IDisposable;
	import stencil.core.engine.TileSettings;

	
	[Event(name="stnSectionCreate",type="stencil.core.engine.display.events.TileRenderEvent")]
		
	[Event(name="stnSectionRemove", type="stencil.core.engine.display.events.TileRenderEvent")] 
	
	[Event(name="stnSectionRedraw",type="stencil.core.engine.display.events.TileRenderEvent")] 
	
	[Event(name="stnSectionUpdate", type="stencil.core.engine.display.events.TileRenderEvent")] 
	
	[Event(name="stnBeginRender",type="stencil.core.engine.display.events.TileRenderEvent")] 
	 
	[Event(name="stnCompleteRender",type="stencil.core.engine.display.events.TileRenderEvent")] 
	
	/**
	 * 
	 * The interface that defines methods for rendering tile sections.
	 * 
	 * @author Max Zhuravkov
	 */
	public interface ITileRenderer extends IEventDispatcher {
		
		
		/**
		 * Determines dimensions and other properties of tiles to be drawn.
		 */
		function set tileSettings(value:TileSettings):void;
		
		function get tileSettings():TileSettings;
		
		/**
		 * Determines whether to show grid or not.
		 */
		function set showGrid(value:Boolean):void;
		
		function get showGrid():Boolean;
		
		/**
		 * The grid.
		 */
		function set grid(value:IGrid):void;
		
		function get grid():IGrid;
		
		/**
		 * The array of recently drawn tile sections.
		 */
		function get tiles():Array;
		
		/**
		 * The number of tile sections to be drawn by one 'render' call
		 */
		function set renderCount(value:int):void;
		
		function get renderCount():int;
		
		/**
		 * All recently drawn tiles sections (if any) will be replaced with new group during next <code>render</code> method call .
		 * 
		 * @param	sections the group of tile sections to be drawn.
		 */
		function draw(tileSections:Array):void;
		
		/**
		 * Removes all tile sections.
		 */
		function clear():void;
		
		/**
		 * Redraws upeviously drawn tile section.
		 * 
		 * @param	tileSection		the tile section.
		 */
		function redrawTiles(tileSection:ITileSection):void;
		
		/**
		 * Returns the display object associated with the given tile section.
		 * 
		 * @param	tileSection		the tile section.
		 * 
		 * @return	a display object if passed section were drawn and null otherwise.
		 */
		function getDisplayObject(tileSection:ITileSection):IDisplayObject;
		
		/**
		 * Draws new tile sections and removes not used ones.
		 * 
		 * 1) draws new tile sections if any (for each one event TileRenderEvent.SECTION_DRAW occurs)
		 * 2) removes not used tile sections (an event TileRenderEvent.SECTION_REMOVE occurs)
		 * 3) for each redrawn tile section (an event TileRenderEvent.SECTION_REDRAW occurs).
		 * 4) for other tile sections an event TileRenderEvent.SECTION_UPDATE occurs.
		 * 
		 */
		function render():void;
		
		/**
		 * Sets grid styles.
		 * 
		 * @param	lineStyle	the line style.
		 * @param	fillStyle	the fill style.
		 */
		function gridStyle(lineStyle:ILineStyle = null, fillStyle:IFillStyle = null):void;
	}
	
}